import {createRouter, createWebHistory} from 'vue-router'
import Layout from "@/layout/index.vue";
import i18n from "../locale";

/**
 * isHideSidebar 是否不显示侧边栏
 * title 路由名称
 */
// 动态加载路由页
export const asyncRoutes = [

    {
        path: '/',
        component: Layout,
        redirect: '/index',
        meta: {
            title: '首页',
        },
        children: [
            {
                path: 'index',
                name: 'Index',
                meta: {
                    title: '首页',
                    icon: 'HomeOutlined',
                },
                component: () => import('@/views/home/index'),
            },
            {
                path: '/merchant',
                component: Layout,
                name: 'Merchant',
                meta: {
                    title:'商户管理',
                    icon: 'TeamOutlined'
                },
                children: [
                    {
                        path: 'merchantList',
                        name: 'MerchantList',
                        meta: {
                            title: '商户列表',
                        },
                        component: () => import('@/views/merchant/merchantList/index'),
                    },
                    {
                        path: 'merchantInfo',
                        name: 'MerchantInfo',
                        meta: {
                            title: '商户信息',
                            isHideSidebar: true
                        },
                        component: () => import('@/views/merchant/merchantInfo/index'),
                    }
                ],
            },
            {
                path: '/merchantCenter',
                component: Layout,
                name: 'MerchantCenter',
                meta: {
                    title: '商户中心',
                },
                children: [
                    {
                        path: 'merchantInformation',
                        name: 'MerchantInformation',
                        meta: {
                            title: '商户信息',
                        },
                        component: () => import('@/views/merchantCenter/merchantInformation/index'),
                    },
                    {
                        path: 'applicationList',
                        name: 'ApplicationList',
                        meta: {
                            title: '应用列表',
                        },
                        component: () => import('@/views/merchantCenter/applicationList/index'),
                    },
                    {
                        path: 'securityConfig',
                        name: 'SecurityConfig',
                        meta: {
                            title: '安全设置',
                        },
                        component: () => import('@/views/merchantCenter/securityConfig/index'),
                    },
                    {
                        path: 'virtualCard',
                        name: 'VirtualCard',
                        meta: {
                            title: '虚拟卡列表',
                        },
                        component: () => import('@/views/merchantCenter/virtualCard/index'),
                    }
                ],
            },
            {
                path: '/capital',
                component: Layout,
                name: 'Capital',
                meta: {
                    title: '资金管理',
                    icon: 'TransactionOutlined'
                },
                children: [
                    {
                        path: 'rechargeList',
                        name: 'RechargeList',
                        meta: {
                            title: '充值列表',
                        },
                        component: () => import('@/views/capital/rechargeList/index'),
                    },
                    {
                        path: 'withdrawalList',
                        name: 'WithdrawalList',
                        meta: {
                            title: '提现列表',
                        },
                        component: () => import('@/views/capital/withdrawalList/index'),
                    },
                    {
                        path: 'transferMoney',
                        name: 'TransferMoney',
                        meta: {
                            title: '商户转账',
                        },
                        component: () => import('@/views/capital/transferMoney/index'),
                    },
                    {
                        path: 'accountDetails',
                        name: 'AccountDetails',
                        meta: {
                            title: '账户明细',
                        },
                        component: () => import('@/views/capital/accountDetails/index'),
                    },
                ],
            },
            {
                path: '/transaction',
                component: Layout,
                name: 'Transaction',
                meta: {
                    title: '交易明细',
                    icon: 'FileSearchOutlined'
                },
                children: [
                    {
                        path: 'loanDetail',
                        name: 'LoanDetail',
                        meta: {
                            title: '出款明细',
                        },
                        component: () => import('@/views/transaction/loanDetail/index'),
                    },
                    {
                        path: 'collectionDetail',
                        name: 'CollectionDetail',
                        meta: {
                            title: '收款明细',
                        },
                        component: () => import('@/views/transaction/collectionDetail/index'),
                    },

                ],
            },
            {
                path: '/paymentDistribution',
                component: Layout,
                name: 'PaymentDistribution',
                meta: {
                    title: '打款分单',
                    icon: 'HddOutlined'
                },
                children: [
                    {
                        path: 'allList',
                        name: 'PaymentDistributionAllList',
                        meta: {
                            title: '全部列表',
                        },
                        component: () => import('@/views/paymentDistribution/allList/index'),
                    },
                    {
                        path: 'agencyList',
                        name: 'PaymentDistributionAgencyList',
                        meta: {
                            title: '待办列表',
                        },
                        component: () => import('@/views/paymentDistribution/agencyList/index'),
                    },
                    {
                        path: 'historyList',
                        name: 'PaymentDistributionHistoryList',
                        meta: {
                            title: '已办列表',
                        },
                        component: () => import('@/views/paymentDistribution/historyList/index'),
                    },

                ],
            },
            {
                path: '/notice',
                name: 'NoticeList',
                component: () => import('@/views/notice/noticeList/index'),
                meta: {
                    title: '通知列表',
                    icon: 'MailOutlined'
                },
            },
            {
                path: '/unCollected',
                name: 'UncollectedList',
                component: () => import('@/views/unCollected/UncollectedList/index'),
                meta: {
                    title: '未收款列表',
                    icon: 'ProfileOutlined'
                },
            },
            {
                path: '/system',
                component: Layout,
                name: 'System',
                meta: {
                    title: '系统设置',
                    icon: 'SettingOutlined'
                },
                children: [
                    {
                        path: 'offlinePayment',
                        name: 'OfflinePayment',
                        meta: {
                            title: '线下打款设置',
                        },
                        component: () => import('@/views/system/offlinePayment/index'),
                    },
                    {
                        path: 'offlinePayChannel',
                        name: 'OfflinePayChannel',
                        meta: {
                            title: '线下支付渠道',
                        },
                        component: () => import('@/views/system/offlinePayChannel/index'),
                    },
                ],
            },
            {
                path: '/authority',
                component: Layout,
                name: 'Authority',
                meta: {
                    title: '权限管理',
                    icon: 'SolutionOutlined'
                },
                children: [
                    {
                        path: 'menuManage',
                        name: 'MenuManage',
                        meta: {
                            title: '菜单管理',
                        },
                        component: () => import('@/views/authority/menuManage/index'),
                    },
                    {
                        path: 'roleManage',
                        name: 'RoleManage',
                        meta: {
                            title: '角色管理',
                        },
                        component: () => import('@/views/authority/roleManage/index'),
                    },
                    {
                        path: 'staffManage',
                        name: 'StaffManage',
                        meta: {
                            title: '员工管理',
                        },
                        component: () => import('@/views/authority/staffManage/index'),
                    },
                ],
            },
        ],
    },

]
export const constantRoutes = [
    {
        path: '/login',
        name: 'login',
        component: () => import('@/components/Login/index'),
    },
    ...asyncRoutes
]
const routerHistory = createWebHistory()
const router = createRouter({
    scrollBehavior() {
        // 始终滚动到顶部
        return {top: 0}
    },
    history: routerHistory,
    routes: constantRoutes
})
export default router
